# Importing Data
EGYPT<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Aluminium/Aluminium.xlsx",sheet = "Sheet1", range = "K1:K229")

# Checking the Imported Data
View(EGYPT)
# Creating Time Series Data
EGYPT_ts <- ts(EGYPT, start=c(1998,1), end=c(2016,12), frequency=12)
# Viewing and Checking the Created Time Series Data
EGYPT_ts
sum(is.na(EGYPT_ts))
library(forecast)
EGYPT_ts <- tsclean(EGYPT_ts)
EGYPT_ts

# Identification: Plotting the Time Series Data
plot(EGYPT_ts)

# Estimating the appropriate model
EGYPT_ts_model <- auto.arima(EGYPT_ts)
EGYPT_ts_model

# Forecasting
options(max.print=1000000)
EGYPT_ts_forecast <- forecast (EGYPT_ts_model, level=c(95), h=288)
plot(EGYPT_ts_forecast)
EGYPT_ts_forecast             

# Exporting
write.table(EGYPT_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Aluminium/EGYPT_TSA.csv", sep=",")
